package com.flw.eslab.interceptor;

import java.util.Map;

import org.apache.struts2.dispatcher.ServletDispatcherResult;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class ExSQLInject implements Interceptor {

	private static final long serialVersionUID = -9187526724024339306L;

	@Override
	public void destroy() {

	}

	@Override
	public void init() {

	}

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {

		Map<String, Object> params = arg0.getInvocationContext()
				.getParameters();
		for (String key : params.keySet()) {
			Object obj = params.get(key);

			if (obj instanceof String[]) {
				String[] arr = (String[]) obj;
				System.out.println("param:" + key);
				for (String string : arr) {
					System.out.println(string);
				}
			}
		}
		String resuleCode = arg0.invoke();
		Result result = arg0.getResult();
		if (result instanceof ServletDispatcherResult) {
			ServletDispatcherResult res = (ServletDispatcherResult) result;
			System.out.println("JSP:" + res.getLastFinalLocation());
		}
		System.out.println("end---------------------");
		return resuleCode;

	}

}
